/*
 * Lenovo Group
 * Copyright (c) 2015-2016 All Rights Reserved.
 * Project Name: lmrp-android app
 * Create Time: 16-2-16 下午6:32
 */

package com.lenovo.mso2o.rest;

import com.lenovo.framework.entity.Res;
import com.lenovo.mso2o.entity.BillNumber;
import com.lenovo.mso2o.entity.GrabResult;
import com.lenovo.mso2o.entity.Order;
import com.lenovo.mso2o.entity.OrderAttachmentListPageRequest;
import com.lenovo.mso2o.entity.OrderAttachmentRes;
import com.lenovo.mso2o.entity.OrderBillingRequest;
import com.lenovo.mso2o.entity.OrderBillingRes;
import com.lenovo.mso2o.entity.OrderDetailRes;
import com.lenovo.mso2o.entity.OrderListRequest;
import com.lenovo.mso2o.entity.OrderUpdatingRequest;
import com.lenovo.mso2o.entity.Status;
import com.lenovo.mso2o.entity.g.Project;
import com.lenovo.mso2o.entity.g.Site;

import java.util.ArrayList;
import java.util.Map;

import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Part;
import retrofit2.http.Path;
import retrofit2.http.Query;
import rx.Observable;

/**
 * Created by lenovo on 2015/11/11.
 */
public interface OrderAPI {

    //获取工程师工单数量
    @GET("tickets/total")
    Observable<Res<BillNumber>> updateNumber();

    @GET("tickets/grab/result/{ticketid}")
    Observable<Res<GrabResult>> updateGrabRes(@Path("ticketid") String ticketid);

    @POST("tickets")
    Observable<Res<ArrayList<Order>>> orderList(@Body OrderListRequest ticketsRequest);

    @POST("api/repairBill/siteList")
    @FormUrlEncoded
    Call<Res<ArrayList<Site>>> siteList(@Field("keyWord") String keyWord);

    @POST("api/repairBill/rapidRepairBill")
    @FormUrlEncoded
    Call<Res> siteList(@FieldMap Map<String, String> params);

    @POST("api/repairBill/billStatusList")
    Call<Res<ArrayList<Status>>> statusList();

    @POST("api/repairBill/projectList")
    Call<Res<ArrayList<Project>>> projectList();

    @POST("api/repairBill/savePageInfo")
    @FormUrlEncoded
    Observable<Res> savePageInfo(@Field("billId") String billId, @Field("stepConfigId") String stepConfigId, @Field("status") String status);
    //3.4获取工单明细
    @GET ("tickets/{ticketid}")
    Observable<Res<OrderDetailRes>> orderDetail(@Path("ticketid") String ticket_id);
    //3.5获取工单明细页面
    @GET ("tickets/{ticketid}/detailpage")
    Observable<Res> detailPage(@Path("ticketid") String ticket_id, @Query("status") String status);
    //3.6获取工单附件列表
    @GET("tickets/{ticketid}/attchments")
    Observable<Res<OrderAttachmentRes>> orderAttachment(@Path("ticketid") String ticket_id);
    //3.7获取工单附件列表页面
    @GET("tickets/{ticketid}/attchments/listpage")
    Observable<Res> orderAttachmentPage(@Body OrderAttachmentListPageRequest orderAttachmentListPageRequest);
    //3.8更新工单,路径需要加上api
    @PUT ("tickets/{ticketid}/{action}")
    Observable<Res> updateOrder(@Path("ticketid") String ticket_id,@Path("action") String action,@Body OrderUpdatingRequest orderUpdatingRequest);

    @PUT ("tickets/{ticketid}/{action}")
    Observable<Res<String>> updateOrderAppoint(@Path("ticketid") String ticket_id,@Path("action") String action,@Body OrderUpdatingRequest orderUpdatingRequest);
    //3.9开单,路径需要加上api
    @POST ("tickets/")
    Observable<Res<OrderBillingRes>> billing(@Body OrderBillingRequest orderBillingRequest);
    //3.10 获取开单页面,路径需要加上api
    @GET("tickets/openpage")
    Observable<Res> getOpenPage();

    //3.20上传工单附件
    @POST("tickets/{ticketid}/attachments")
    @Multipart
    Observable<Res> uploadOrderAttachment(@Part("itsmcode") RequestBody itsmcode,@Part("ticketid") RequestBody ticket_id,@Part("action")RequestBody action,@Part("attachment") RequestBody attachment,@Part("content")RequestBody content);
    //3.21 获取工单工作流页面
    @GET("ticketes/{ticketid}/processpage")
    Observable<Res> processpage(@Path("ticketid") String ticket_id);
    //3.22 获取工单工作流活动节点页面
    @GET("ticketes/{ticketid}/{activityid}/activepage")
    Observable<Res> activepage(@Path("ticketid") String ticket_id,@Path("activityid") String activity_id);
}
